package com.qingzhu.dao.impl;

import com.qingzhu.dao.ProvincesDao;
import com.qingzhu.pojo.Provinces;
import com.qingzhu.util.CreateSqlSessionFactory;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ProvincesDaoImpl implements ProvincesDao {

    @Override
    public List<Provinces> findProvinces() {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)) {
            ProvincesDao provincesDao = sqlSession.getMapper(ProvincesDao.class);
            return provincesDao.findProvinces();
        }
    }

    @Override
    public Provinces findProvincesById(String provinceId) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)) {
            ProvincesDao provincesDao = sqlSession.getMapper(ProvincesDao.class);
            return provincesDao.findProvincesById(provinceId);
        }
    }
}
